from typing import List


class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next



def create_list_node(nums:List[int])->ListNode:
    """ ListNode转数组 """
    root=ListNode()
    temp=root
    for n in nums:
        node=ListNode(n)
        temp.next=node
        temp=temp.next
    return root.next

def calc_arr(root:ListNode)->List[int]:
    """ 数组转ListNode """
    lis=[]
    temp=root
    while temp:
        lis.append(temp.val)
        temp=temp.next
    return lis